from selenium import webdriver
from lxml import etree


url = 'https://movie.douban.com/subject/27605698/comments?start={}&limit=20&sort=new_score&status=P'
login_url = 'https://www.douban.com/accounts/login'
driver = webdriver.Chrome()
driver.get(login_url)
driver.find_element_by_id('email').send_keys('15618226395')
driver.find_element_by_id('password').send_keys('s1217y29l')
driver.find_element_by_name('login').click()


url_list = list(range(0,500,20))
while len(url_list) > 0:
    page_url = url.format(url_list.pop())
    driver.get(page_url)
    element = etree.HTML(driver.page_source)
    for div in element.xpath('//div[@id="comments"]/div'):
        comment = div.xpath('.//span[@class="short"]/text()')


